package com.ftg.learn.springboot.demo.controller;

import com.ftg.learn.springboot.demo.pojo.Student;
import com.ftg.learn.springboot.demo.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@CrossOrigin
@RequestMapping("student")
public class DemoController {
	@Autowired
	StudentService ss;

	@GetMapping("/show")
	public Map<String, Object> showAll(int page, int limit,String deptno) {
		Map<String, Object> map = new HashMap<>();
		List<Student> list = ss.showAll(page,limit,deptno);
		map.put("data",list);
		map.put("code", 0);
		map.put("count", ss.getcount(deptno));
		map.put("msg", "到哪里?");

		return map;
	}

	@DeleteMapping("/del/{id}")
	public int del(@PathVariable int id) {
		return ss.del(id);
	}

	@PostMapping("/update")
	public int update(Student student) {
		return ss.update(student);
	}

	@PostMapping("/add")

	public int add(Student student) {


		return ss.add(student);
	}

}
